{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "iQqHW_jdrgGa"
   },
   "source": [
    "# **If you are using Colab for free, we highly recommend you activate the T4 GPU hardware accelerator. Our models are designed to run with at least 16GB of RAM, activating T4 will grant the notebook 16GB of GDDR6 RAM as opposed to the 13GB Colab gives automatically.**\n",
    "# **To active T4:**\n",
    "# **1.   click on the \"Runtime\" tab**\n",
    "# **2.   click on \"Change runtime type\"**\n",
    "# **3.   select T4 GPU under Hardware Accelerator**\n",
    "# **NOTE: there is a weekly usage limit on using T4 for free**\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "h3wwcTnayFTw",
    "outputId": "e7dd0212-9398-4ddf-f17a-f5a83f29f40e"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting llmware\n",
      "  Downloading llmware-0.3.0-py3-none-any.whl (56.0 MB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m56.0/56.0 MB\u001b[0m \u001b[31m7.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hCollecting boto3>=1.24.53 (from llmware)\n",
      "  Downloading boto3-1.34.120-py3-none-any.whl (139 kB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m139.3/139.3 kB\u001b[0m \u001b[31m698.5 kB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hRequirement already satisfied: huggingface-hub>=0.19.4 in /usr/local/lib/python3.10/dist-packages (from llmware) (0.23.2)\n",
      "Requirement already satisfied: numpy>=1.23.2 in /usr/local/lib/python3.10/dist-packages (from llmware) (1.25.2)\n",
      "Collecting pymongo>=4.7.0 (from llmware)\n",
      "  Downloading pymongo-4.7.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (669 kB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m669.1/669.1 kB\u001b[0m \u001b[31m7.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hRequirement already satisfied: tokenizers>=0.15.0 in /usr/local/lib/python3.10/dist-packages (from llmware) (0.19.1)\n",
      "Collecting psycopg-binary==3.1.17 (from llmware)\n",
      "  Downloading psycopg_binary-3.1.17-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.3/3.3 MB\u001b[0m \u001b[31m33.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hCollecting psycopg==3.1.17 (from llmware)\n",
      "  Downloading psycopg-3.1.17-py3-none-any.whl (178 kB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m178.0/178.0 kB\u001b[0m \u001b[31m11.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hCollecting pgvector==0.2.4 (from llmware)\n",
      "  Downloading pgvector-0.2.4-py2.py3-none-any.whl (9.6 kB)\n",
      "Collecting colorama==0.4.6 (from llmware)\n",
      "  Downloading colorama-0.4.6-py2.py3-none-any.whl (25 kB)\n",
      "Requirement already satisfied: librosa>=0.10.0 in /usr/local/lib/python3.10/dist-packages (from llmware) (0.10.2.post1)\n",
      "Requirement already satisfied: typing-extensions>=4.1 in /usr/local/lib/python3.10/dist-packages (from psycopg==3.1.17->llmware) (4.12.1)\n",
      "Collecting botocore<1.35.0,>=1.34.120 (from boto3>=1.24.53->llmware)\n",
      "  Downloading botocore-1.34.120-py3-none-any.whl (12.3 MB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m12.3/12.3 MB\u001b[0m \u001b[31m31.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hCollecting jmespath<2.0.0,>=0.7.1 (from boto3>=1.24.53->llmware)\n",
      "  Downloading jmespath-1.0.1-py3-none-any.whl (20 kB)\n",
      "Collecting s3transfer<0.11.0,>=0.10.0 (from boto3>=1.24.53->llmware)\n",
      "  Downloading s3transfer-0.10.1-py3-none-any.whl (82 kB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m82.2/82.2 kB\u001b[0m \u001b[31m4.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hRequirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.4->llmware) (3.14.0)\n",
      "Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.4->llmware) (2023.6.0)\n",
      "Requirement already satisfied: packaging>=20.9 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.4->llmware) (24.0)\n",
      "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.4->llmware) (6.0.1)\n",
      "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.4->llmware) (2.31.0)\n",
      "Requirement already satisfied: tqdm>=4.42.1 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.4->llmware) (4.66.4)\n",
      "Requirement already satisfied: audioread>=2.1.9 in /usr/local/lib/python3.10/dist-packages (from librosa>=0.10.0->llmware) (3.0.1)\n",
      "Requirement already satisfied: scipy>=1.2.0 in /usr/local/lib/python3.10/dist-packages (from librosa>=0.10.0->llmware) (1.11.4)\n",
      "Requirement already satisfied: scikit-learn>=0.20.0 in /usr/local/lib/python3.10/dist-packages (from librosa>=0.10.0->llmware) (1.2.2)\n",
      "Requirement already satisfied: joblib>=0.14 in /usr/local/lib/python3.10/dist-packages (from librosa>=0.10.0->llmware) (1.4.2)\n",
      "Requirement already satisfied: decorator>=4.3.0 in /usr/local/lib/python3.10/dist-packages (from librosa>=0.10.0->llmware) (4.4.2)\n",
      "Requirement already satisfied: numba>=0.51.0 in /usr/local/lib/python3.10/dist-packages (from librosa>=0.10.0->llmware) (0.58.1)\n",
      "Requirement already satisfied: soundfile>=0.12.1 in /usr/local/lib/python3.10/dist-packages (from librosa>=0.10.0->llmware) (0.12.1)\n",
      "Requirement already satisfied: pooch>=1.1 in /usr/local/lib/python3.10/dist-packages (from librosa>=0.10.0->llmware) (1.8.1)\n",
      "Requirement already satisfied: soxr>=0.3.2 in /usr/local/lib/python3.10/dist-packages (from librosa>=0.10.0->llmware) (0.3.7)\n",
      "Requirement already satisfied: lazy-loader>=0.1 in /usr/local/lib/python3.10/dist-packages (from librosa>=0.10.0->llmware) (0.4)\n",
      "Requirement already satisfied: msgpack>=1.0 in /usr/local/lib/python3.10/dist-packages (from librosa>=0.10.0->llmware) (1.0.8)\n",
      "Collecting dnspython<3.0.0,>=1.16.0 (from pymongo>=4.7.0->llmware)\n",
      "  Downloading dnspython-2.6.1-py3-none-any.whl (307 kB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m307.7/307.7 kB\u001b[0m \u001b[31m17.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hRequirement already satisfied: python-dateutil<3.0.0,>=2.1 in /usr/local/lib/python3.10/dist-packages (from botocore<1.35.0,>=1.34.120->boto3>=1.24.53->llmware) (2.8.2)\n",
      "Requirement already satisfied: urllib3!=2.2.0,<3,>=1.25.4 in /usr/local/lib/python3.10/dist-packages (from botocore<1.35.0,>=1.34.120->boto3>=1.24.53->llmware) (2.0.7)\n",
      "Requirement already satisfied: llvmlite<0.42,>=0.41.0dev0 in /usr/local/lib/python3.10/dist-packages (from numba>=0.51.0->librosa>=0.10.0->llmware) (0.41.1)\n",
      "Requirement already satisfied: platformdirs>=2.5.0 in /usr/local/lib/python3.10/dist-packages (from pooch>=1.1->librosa>=0.10.0->llmware) (4.2.2)\n",
      "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.19.4->llmware) (3.3.2)\n",
      "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.19.4->llmware) (3.7)\n",
      "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.19.4->llmware) (2024.6.2)\n",
      "Requirement already satisfied: threadpoolctl>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from scikit-learn>=0.20.0->librosa>=0.10.0->llmware) (3.5.0)\n",
      "Requirement already satisfied: cffi>=1.0 in /usr/local/lib/python3.10/dist-packages (from soundfile>=0.12.1->librosa>=0.10.0->llmware) (1.16.0)\n",
      "Requirement already satisfied: pycparser in /usr/local/lib/python3.10/dist-packages (from cffi>=1.0->soundfile>=0.12.1->librosa>=0.10.0->llmware) (2.22)\n",
      "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.35.0,>=1.34.120->boto3>=1.24.53->llmware) (1.16.0)\n",
      "Installing collected packages: psycopg-binary, psycopg, pgvector, jmespath, dnspython, colorama, pymongo, botocore, s3transfer, boto3, llmware\n",
      "Successfully installed boto3-1.34.120 botocore-1.34.120 colorama-0.4.6 dnspython-2.6.1 jmespath-1.0.1 llmware-0.3.0 pgvector-0.2.4 psycopg-3.1.17 psycopg-binary-3.1.17 pymongo-4.7.3 s3transfer-0.10.1\n"
     ]
    }
   ],
   "source": [
    "!pip install llmware"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "SmOaSv8_yWDw"
   },
   "outputs": [],
   "source": [
    "import os\n",
    "from llmware.library import Library\n",
    "from llmware.retrieval import Query\n",
    "from llmware.setup import Setup\n",
    "from llmware.configs import LLMWareConfig"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "yBR2N26tyg9E"
   },
   "outputs": [],
   "source": [
    "LLMWareConfig().set_active_db(\"sqlite\")\n",
    "LLMWareConfig().set_config(\"debug_mode\", 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "kLLaRPK8y92L"
   },
   "outputs": [],
   "source": [
    "sample_folders = [\"Agreements\", \"Invoices\", \"UN-Resolutions-500\", \"SmallLibrary\", \"FinDocs\", \"AgreementsLarge\"]\n",
    "library_name = \"example1_library\"\n",
    "selected_folder = sample_folders[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "wnGCyOkYze-a",
    "outputId": "d9d56aa3-7ec4-4b6b-9513-d13ab537ff09"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Example - Parsing Files into Library\n",
      "\n",
      "Step 1 - creating library example1_library\n"
     ]
    }
   ],
   "source": [
    "print(f\"\\nExample - Parsing Files into Library\")\n",
    "print(f\"\\nStep 1 - creating library {library_name}\")\n",
    "library = Library().create_new_library(library_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "0grz6kFBz4C9",
    "outputId": "82530467-780e-42d0-b4dc-7a61977a9f16"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Step 2 - loading the llmware sample files and saving at: /root/llmware_data/sample_files\n"
     ]
    }
   ],
   "source": [
    "sample_files_path = Setup().load_sample_files(over_write=False)\n",
    "print(f\"Step 2 - loading the llmware sample files and saving at: {sample_files_path}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "8jbY2jP_0D-9",
    "outputId": "5682b88c-de56-459b-a8fb-a5fb3fe711a6"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Step 3 - parsing and indexing files from /root/llmware_data/sample_files/Agreements\n"
     ]
    }
   ],
   "source": [
    "ingestion_folder_path = os.path.join(sample_files_path, selected_folder)\n",
    "print(f\"Step 3 - parsing and indexing files from {ingestion_folder_path}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "VW-upUwa0SrA",
    "outputId": "4ea25ddd-5318-4b21-f18b-b79fbafb3af0"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Step 4 - completed parsing - {'docs_added': 15, 'blocks_added': 2211, 'images_added': 0, 'pages_added': 204, 'tables_added': 0, 'rejected_files': []}\n"
     ]
    }
   ],
   "source": [
    "parsing_output = library.add_files(ingestion_folder_path)\n",
    "print(f\"Step 4 - completed parsing - {parsing_output}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "S4Sx-o-s0cj6",
    "outputId": "26fc3037-d227-45d8-b253-9a2d7a651300"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Step 5 - updated library card - documents - 15 - blocks - 2211 - {'_id': 1, 'library_name': 'example1_library', 'embedding': [{'embedding_status': 'no', 'embedding_model': 'none', 'embedding_db': 'none', 'embedded_blocks': 0, 'embedding_dims': 0, 'time_stamp': 'NA'}], 'knowledge_graph': 'no', 'unique_doc_id': 15, 'documents': 15, 'blocks': 2211, 'images': 0, 'pages': 204, 'tables': 0, 'account_name': 'llmware'}\n"
     ]
    }
   ],
   "source": [
    "updated_library_card = library.get_library_card()\n",
    "doc_count = updated_library_card[\"documents\"]\n",
    "block_count = updated_library_card[\"blocks\"]\n",
    "print(f\"Step 5 - updated library card - documents - {doc_count} - blocks - {block_count} - {updated_library_card}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "IsZgenlo079L",
    "outputId": "2e9aeaad-34f0-4218-8d1e-3e4b5288b218"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Step 6 - library artifacts - including extracted images - saved at folder path - /root/llmware_data/accounts/llmware/example1_library\n"
     ]
    }
   ],
   "source": [
    "library_path = library.library_main_path\n",
    "print(f\"Step 6 - library artifacts - including extracted images - saved at folder path - {library_path}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "szyPVmi81Fh6",
    "outputId": "b159172b-b8c1-4f39-bc19-753c8b401580"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Step 7 - running a test query - base salary\n",
      "\n",
      "query results:  0 {'query': 'base salary', '_id': '1663', 'text': \" Base Salary. For all the services rendered by Executive hereunder, during the Employment Period,   Employer shall pay Executive a base salary at the annual rate of $200,000, payable semimonthly in   accordance with Employer's normal payroll practices. Executive's base salary shall be reviewed annually   by the Board (or the compensation committee of the Board), pursuant to Employer's normal   compensation \", 'doc_ID': 12, 'block_ID': 33, 'page_num': 3, 'content_type': 'text', 'author_or_speaker': '', 'special_field1': '', 'file_source': 'Metis EXECUTIVE EMPLOYMENT AGREEMENT.pdf', 'added_to_collection': 'Thu Jun  6 13:51:29 2024', 'table': '', 'coords_x': 427, 'coords_y': -1681, 'coords_cx': 2, 'coords_cy': 123, 'external_files': '', 'score': -8.71512754073446, 'similarity': 0.0, 'distance': 0.0, 'matches': [[1, 'base'], [6, 'salary'], [131, 'base'], [136, 'salary'], [265, 'base'], [270, 'salary']], 'account_name': 'llmware', 'library_name': 'example1_library'}\n",
      "query results:  1 {'query': 'base salary', '_id': '1807', 'text': \" Base Salary. For all the services rendered by Executive hereunder, during the Employment Period,   Employer shall pay Executive a base salary at the annual rate of $4350,000, payable semimonthly in   accordance with Employer's normal payroll practices. Executive's base salary shall be reviewed annually   by the Board (or the compensation committee of the Board), pursuant to Employer's normal   compensation \", 'doc_ID': 13, 'block_ID': 33, 'page_num': 3, 'content_type': 'text', 'author_or_speaker': '', 'special_field1': '', 'file_source': 'Rhea EXECUTIVE EMPLOYMENT AGREEMENT.pdf', 'added_to_collection': 'Thu Jun  6 13:51:29 2024', 'table': '', 'coords_x': 427, 'coords_y': -1681, 'coords_cx': 2, 'coords_cy': 122, 'external_files': '', 'score': -8.71512754073446, 'similarity': 0.0, 'distance': 0.0, 'matches': [[1, 'base'], [6, 'salary'], [131, 'base'], [136, 'salary'], [266, 'base'], [271, 'salary']], 'account_name': 'llmware', 'library_name': 'example1_library'}\n",
      "query results:  2 {'query': 'base salary', '_id': '2101', 'text': \" Base Salary. For all the services rendered by Executive hereunder, during the Employment Period,   Employer shall pay Executive a base salary at the annual rate of $200,000, payable semimonthly in   accordance with Employer's normal payroll practices. Executive's base salary shall be reviewed annually   by the Board (or the compensation committee of the Board), pursuant to Employer's normal   compensation \", 'doc_ID': 15, 'block_ID': 33, 'page_num': 3, 'content_type': 'text', 'author_or_speaker': '', 'special_field1': '', 'file_source': 'Persephone EXECUTIVE EMPLOYMENT AGREEMENT.pdf', 'added_to_collection': 'Thu Jun  6 13:51:29 2024', 'table': '', 'coords_x': 427, 'coords_y': -1681, 'coords_cx': 2, 'coords_cy': 122, 'external_files': '', 'score': -8.71512754073446, 'similarity': 0.0, 'distance': 0.0, 'matches': [[1, 'base'], [6, 'salary'], [131, 'base'], [136, 'salary'], [265, 'base'], [270, 'salary']], 'account_name': 'llmware', 'library_name': 'example1_library'}\n",
      "query results:  3 {'query': 'base salary', '_id': '22', 'text': \"any such event or condition and   Employer does not fully correct the situation within thirty (30) days after such notice of Good Reason:         (i)  a reduction by Employer in Executive's Base Salary (other than a proportional reduction as part of a   generalized reduction in the base salaries of senior management of the Company not to exceed 5% of   Base Salary then currently in effect);       \", 'doc_ID': 1, 'block_ID': 21, 'page_num': 2, 'content_type': 'text', 'author_or_speaker': '', 'special_field1': '', 'file_source': 'Leto EXECUTIVE EMPLOYMENT AGREEMENT.pdf', 'added_to_collection': 'Thu Jun  6 13:51:29 2024', 'table': '', 'coords_x': 250, 'coords_y': -1687, 'coords_cx': 1, 'coords_cy': 130, 'external_files': '', 'score': -8.240641465648865, 'similarity': 0.0, 'distance': 0.0, 'matches': [[190, 'base'], [195, 'salary'], [283, 'base'], [355, 'base'], [360, 'salary']], 'account_name': 'llmware', 'library_name': 'example1_library'}\n",
      "query results:  4 {'query': 'base salary', '_id': '166', 'text': \"any such event or condition and   Employer does not fully correct the situation within thirty (30) days after such notice of Good Reason:         (i)  a reduction by Employer in Executive's Base Salary (other than a proportional reduction as part of a   generalized reduction in the base salaries of senior management of the Company not to exceed 5% of   Base Salary then currently in effect);       \", 'doc_ID': 2, 'block_ID': 21, 'page_num': 2, 'content_type': 'text', 'author_or_speaker': '', 'special_field1': '', 'file_source': 'Nyx EXECUTIVE EMPLOYMENT AGREEMENT.pdf', 'added_to_collection': 'Thu Jun  6 13:51:29 2024', 'table': '', 'coords_x': 250, 'coords_y': -1687, 'coords_cx': 1, 'coords_cy': 130, 'external_files': '', 'score': -8.240641465648865, 'similarity': 0.0, 'distance': 0.0, 'matches': [[190, 'base'], [195, 'salary'], [283, 'base'], [355, 'base'], [360, 'salary']], 'account_name': 'llmware', 'library_name': 'example1_library'}\n",
      "query results:  5 {'query': 'base salary', '_id': '760', 'text': \"any such event or condition and   Employer does not fully correct the situation within thirty (30) days after such notice of Good Reason:         (i)  a reduction by Employer in Executive's Base Salary (other than a proportional reduction as part of a   generalized reduction in the base salaries of senior management of the Company not to exceed 5% of   Base Salary then currently in effect);       \", 'doc_ID': 6, 'block_ID': 21, 'page_num': 2, 'content_type': 'text', 'author_or_speaker': '', 'special_field1': '', 'file_source': 'Gaia EXECUTIVE EMPLOYMENT AGREEMENT.pdf', 'added_to_collection': 'Thu Jun  6 13:51:29 2024', 'table': '', 'coords_x': 250, 'coords_y': -1687, 'coords_cx': 1, 'coords_cy': 130, 'external_files': '', 'score': -8.240641465648865, 'similarity': 0.0, 'distance': 0.0, 'matches': [[190, 'base'], [195, 'salary'], [283, 'base'], [355, 'base'], [360, 'salary']], 'account_name': 'llmware', 'library_name': 'example1_library'}\n",
      "query results:  6 {'query': 'base salary', '_id': '1059', 'text': \"any such event or condition and   Employer does not fully correct the situation within thirty (30) days after such notice of Good Reason:         (i)  a reduction by Employer in Executive's Base Salary (other than a proportional reduction as part of a   generalized reduction in the base salaries of senior management of the Company not to exceed 5% of   Base Salary then currently in effect);       \", 'doc_ID': 8, 'block_ID': 21, 'page_num': 2, 'content_type': 'text', 'author_or_speaker': '', 'special_field1': '', 'file_source': 'Nike EXECUTIVE EMPLOYMENT AGREEMENT.pdf', 'added_to_collection': 'Thu Jun  6 13:51:29 2024', 'table': '', 'coords_x': 250, 'coords_y': -1687, 'coords_cx': 1, 'coords_cy': 130, 'external_files': '', 'score': -8.240641465648865, 'similarity': 0.0, 'distance': 0.0, 'matches': [[190, 'base'], [195, 'salary'], [283, 'base'], [355, 'base'], [360, 'salary']], 'account_name': 'llmware', 'library_name': 'example1_library'}\n",
      "query results:  7 {'query': 'base salary', '_id': '1203', 'text': \"any such event or condition and   Employer does not fully correct the situation within thirty (30) days after such notice of Good Reason:         (i)  a reduction by Employer in Executive's Base Salary (other than a proportional reduction as part of a   generalized reduction in the base salaries of senior management of the Company not to exceed 5% of   Base Salary then currently in effect);       \", 'doc_ID': 9, 'block_ID': 21, 'page_num': 2, 'content_type': 'text', 'author_or_speaker': '', 'special_field1': '', 'file_source': 'Demeter EXECUTIVE EMPLOYMENT AGREEMENT.pdf', 'added_to_collection': 'Thu Jun  6 13:51:29 2024', 'table': '', 'coords_x': 250, 'coords_y': -1687, 'coords_cx': 1, 'coords_cy': 130, 'external_files': '', 'score': -8.240641465648865, 'similarity': 0.0, 'distance': 0.0, 'matches': [[190, 'base'], [195, 'salary'], [283, 'base'], [355, 'base'], [360, 'salary']], 'account_name': 'llmware', 'library_name': 'example1_library'}\n",
      "query results:  8 {'query': 'base salary', '_id': '1352', 'text': \"any such event or condition and   Employer does not fully correct the situation within thirty (30) days after such notice of Good Reason:         (i)  a reduction by Employer in Executive's Base Salary (other than a proportional reduction as part of a   generalized reduction in the base salaries of senior management of the Company not to exceed 5% of   Base Salary then currently in effect);       \", 'doc_ID': 10, 'block_ID': 21, 'page_num': 2, 'content_type': 'text', 'author_or_speaker': '', 'special_field1': '', 'file_source': 'Eileithyia EXECUTIVE EMPLOYMENT AGREEMENT.pdf', 'added_to_collection': 'Thu Jun  6 13:51:29 2024', 'table': '', 'coords_x': 250, 'coords_y': -1687, 'coords_cx': 1, 'coords_cy': 130, 'external_files': '', 'score': -8.240641465648865, 'similarity': 0.0, 'distance': 0.0, 'matches': [[190, 'base'], [195, 'salary'], [283, 'base'], [355, 'base'], [360, 'salary']], 'account_name': 'llmware', 'library_name': 'example1_library'}\n",
      "query results:  9 {'query': 'base salary', '_id': '1651', 'text': \"any such event or condition and   Employer does not fully correct the situation within thirty (30) days after such notice of Good Reason:         (i)  a reduction by Employer in Executive's Base Salary (other than a proportional reduction as part of a   generalized reduction in the base salaries of senior management of the Company not to exceed 5% of   Base Salary then currently in effect);       \", 'doc_ID': 12, 'block_ID': 21, 'page_num': 2, 'content_type': 'text', 'author_or_speaker': '', 'special_field1': '', 'file_source': 'Metis EXECUTIVE EMPLOYMENT AGREEMENT.pdf', 'added_to_collection': 'Thu Jun  6 13:51:29 2024', 'table': '', 'coords_x': 250, 'coords_y': -1687, 'coords_cx': 1, 'coords_cy': 130, 'external_files': '', 'score': -8.240641465648865, 'similarity': 0.0, 'distance': 0.0, 'matches': [[190, 'base'], [195, 'salary'], [283, 'base'], [355, 'base'], [360, 'salary']], 'account_name': 'llmware', 'library_name': 'example1_library'}\n"
     ]
    }
   ],
   "source": [
    "test_query = \"base salary\"\n",
    "print(f\"\\nStep 7 - running a test query - {test_query}\\n\")\n",
    "query_results = Query(library).text_query(test_query, result_count=10)\n",
    "for i, result in enumerate(query_results):\n",
    "  text = result[\"text\"]\n",
    "  file_source = result[\"file_source\"]\n",
    "  page_number = result[\"page_num\"]\n",
    "  doc_id = result[\"doc_ID\"]\n",
    "  block_id = result[\"block_ID\"]\n",
    "  matches = result[\"matches\"]\n",
    "  print(\"query results: \", i, result)"
   ]
  }
 ],
 "metadata": {
  "colab": {
   "provenance": []
  },
  "kernelspec": {
   "display_name": "Python 3",
   "name": "python3"
  },
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
